<?php
include_once("../../../common/modules/checkA.php");
include_once("../../../../config.php");
?>


<?

//接收需要修改的数据的id
$new_detail_nid = addslashes($_REQUEST['nid']);


$_REQUEST['ai_starttime'] = $_REQUEST['ai_starttime'] == '' ? '' : addslashes($_REQUEST['ai_starttime']);
$_REQUEST['ai_endtime']   = $_REQUEST['ai_endtime']   == '' ? '' : addslashes($_REQUEST['ai_endtime']);
$_REQUEST['ai_tag']   = implode(',',$_REQUEST['ai_tag']);
$_REQUEST['ai_group_nid']   = implode(',',$_REQUEST['ai_group_nid']);


//leader项是前端列表要读取的，需要补一下
//获取局长信息
$leader=select_one_line_all_items($table_Prefix."member","nid = '".$_REQUEST['ai_employee_id']."' ");
$_REQUEST['ai_leader'] = $leader['nickname'];

include_once("mod-images-upload-function.php");


//设置需要搜索的表格的前缀后缀
$table        = $table_Prefix . "event";
$sql=update_date($table,$_REQUEST,"nid",$new_detail_nid);
$query = do_query($sql) or die (mysqli_error().mysqli_errno().$sql);




if($query){
    //发送流局通知
    if($_REQUEST['event_status'] == 2){

        //获取活动的参与人员,记得排除已经退款的。
        $member_list = select_lines_all_items($table_Prefix."event_member",'nid desc' , 'event_nid ='.$_REQUEST['nid']." and is_delete = 0");

        foreach ($member_list as $key=>$v){
            $member = select_one_line_all_items($table_Prefix."member",'nid ='.$v['user_id'] );
            $wechat_member = select_one_line_all_items($table_Prefix."wechat_member","unionid = '".$member['unionid']."'");

            //curl 一个api地址，带上通知内容代号，被通知人，然后就触发了。
            $_url=$domain."/api/wechat_message/notice_event_failed.php?openid=".$wechat_member['openid']."&eventid=".$_REQUEST['nid'];
            file_get_contents($_url);
        }

        //给局长发送通知---start---
        $leader = select_one_line_all_items($table_Prefix."member",' nid='.$_REQUEST['employee_id']);
        $leader_wechat_member = select_one_line_all_items($table_Prefix."wechat_member","unionid = '".$leader['unionid']."'");
        $leader_url=$domain."/api/wechat_message/notice_event_failed.php?openid=".$leader_wechat_member['openid']."&eventid=".$_REQUEST['nid'];
        file_get_contents($leader_url);
        //------end---
    }
}

mysqli_close($con);

?>



<?

$nowpageid = $_GET["nowpageid"];

?>


<script type="text/javascript">

     alert("输入信息已保存，点击确认返回继续操作.");
     document.location.href = "detail-list.php?nowpageid=<? echo $nowpageid ?>&sortby=<? echo $sortby?>&nid=<? echo $term_nid ?>&sys_part=<? echo $system_part ?>"

</script>


</body>
